package com.changgou.goods.feign;

import com.changgou.entity.Result;
import com.changgou.goods.pojo.Sku;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author kfzhao
 * @version 1.0
 * @interfaceName SkuFeign
 * @description feign接口 定义name为要操作的服务名
 * @date 2021/12/27 1:48
 **/
@FeignClient(name = "goods")
//@RequestMapping("/sku")
public interface SkuFeign {

    /**
     * 对外暴露的feign接口
     * 方法名和方法参数可以直接从controller中获取
     *
     * @param spuId
     * @return java.util.List<com.changgou.goods.pojo.Sku>
     * @throws
     * @description
     * @author kfzhao
     * @date 2021/12/27 1:50
     */
    @GetMapping("/sku/spu/{spuId}")
    public List<Sku> findSkuListBySpuId(@PathVariable("spuId") String spuId);

    /**
     * 根据id查找sku
     *
     * @param id
     * @return com.changgou.entity.Result
     * @throws
     * @description
     * @author kfzhao
     * @date 2022/1/3 0:55
     */
    @GetMapping("/sku/{id}")
    public Result<Sku> findById(@PathVariable String id);

    @PostMapping("/sku/decr/count")
    public Result decrCount(@RequestParam("username") String username);

    @RequestMapping("/sku/resumeStockNum")
    public Result resumeStockNum(@RequestParam("skuId") String skuId, @RequestParam("num") Integer num);
}
